﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Skybot.Logs.Broken
{
    /// <summary>
    /// 文件写入磁盘测试
    /// </summary>
    /// <example>
    /// 测试创建多个目录，多个Broken对像同时写文件
    /// </example>
    public class FileWriteToDiskTest
    {

        Dictionary<string, ConnBrokenSupplements> dic = new Dictionary<string, ConnBrokenSupplements>();
        /// <summary>
        /// 初始化方法
        /// </summary>
        public void Init()
        {
            for (int i = 0; i < 16; i++)
            {
                var conn = new ConnBrokenSupplements() { BrokenDir = "xFault" + i, MinuteInterval = 1, FileMaxRecordNumber = 1000, };
                conn.Init(conn.BrokenDir);
                dic.Add(conn.BrokenDir, conn);

            }
        }

        public void 多Supple写入测试()
        {
            for (int i = 0; i < 10000; i++)
            {
                foreach (var item in dic)
                {
 
                    item.Value.Write(Guid.NewGuid().ToByteArray());

                }
            }

        }
        /// <summary>
        /// 超时关闭文件
        /// </summary>
        public void CheckTimeOutCloseFile()
        {
            foreach (var item in dic)
            {
                //检查是否需要换新文件
                item.Value.CheckWrite();
 
            }
        }

    }
}
